package com.oom;

/**
 * @description: 通过创建线程的方式导致栈OOM
 * VM args: -Xss2M 每个线程栈的大小
 * @author: yuchi_huang (yuchi_huang@sui.com)
 * @date: 18/3/15
 * @modified By:
 */
public class JavaVMStackOOM {

    private void dontStop(){
        while(true){
        }
    }

    public void stackLeakByThead(){

        while(true){

            Thread t = new Thread(new Runnable(){
                @Override
                public void run() {
                    dontStop();
                }
            });
            t.start();

        }

    }

    public static void main(String[] args) {
        JavaVMStackOOM stackOOM = new JavaVMStackOOM();
        stackOOM.stackLeakByThead();
    }
}
